package com.weed.table.rowhead;



import java.awt.Color;
import java.awt.Component;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;

/*** 函数说明：
 *     行头的绘制者。
 * 作者     日期      说明
 * 卓志成   20080119  用于绘制行头。
 *
 */
/**设置行头的绘制者。默认为居中，*/
public class RowHeadTableCellRenderer extends JLabel implements TableCellRenderer {
    Color backgroup = new Color(255,192,111);
    Color oldColor = null;
    private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
    protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER;
    
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus,
            int row, int column) {
        
        setOpaque(true);
        //setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        
        if (isSelected) {
            Color oldColor = this.getBackground();
            this.setBackground(table.getSelectionBackground());
          //  this.setBackground(UIManager.getColor("Panel.bakground"));
         //setHorizontalTextPosition(SwingConstants.LEFT);
        }else{
            this.setBackground(UIManager.getColor("Panel.background"));
            
        }
//        if (row != table.getRowCount())
//        {
////          setText(String.valueOf(row + 1));
//        }
//        else
//        {
//         // setText(String.valueOf(""));
//        }
        return this;
    }
    
}
